home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / keyboard / readchar.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  1.3 KB  |  46 lines

  1. ;char  read_char();
  2.  
  3.     EXTRN  _memory_model:byte
  4.  
  5. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  6.     ASSUME CS:_TEXT
  7.     PUBLIC _read_char
  8. _read_char proc near
  9. L1:    mov  ah,1        ;func to check for char
  10.     int  16h        ;find out next char
  11.     jz   L1            ;loop if no char
  12.     or   al,al        ;is it extended?
  13.     jz   L6            ;read by DOS func if so
  14.     sub  ah,ah        ;BIOS func to read key
  15.     int  16h        ;get the ASCII code
  16.     cmp  al,8        ;is it backspace?
  17.     jne  L2            ;jump ahead if not
  18.     cmp  ah,14        ;is it from backspc key?
  19.     je   l7            ;jump ahead if so
  20.     jmp  short L5        ;else make it 208
  21. L2:    cmp  al,9        ;is it tab?
  22.     jne  L3            ;jump ahead if not
  23.     cmp  ah,15        ;is it from tab key?
  24.     je   L7            ;jump ahead if so
  25.     jmp  short L5        ;else make it 209
  26. L3:    cmp  al,13        ;is it carriage return?
  27.     jne  L4            ;jump ahead if not
  28.     cmp  ah,28        ;is it from CR key?
  29.     je   L7            ;jump ahead if so
  30.     jmp  short L5        ;else make it 213
  31. L4:    cmp  al,27        ;is it escape?
  32.     jne  L7            ;jump ahead if not
  33.     cmp  ah,1        ;is it from escape key?
  34.     je   L7            ;jump ahead if so
  35. L5:    add  al,200        ;inc key code by 200
  36.     jmp  short L7        ;go set char for return
  37. L6:    mov  ah,7        ;DOS keyboard read func
  38.     int  21h        ;get the initial 0
  39. L7:    cmp  _memory_model,0    ;quit
  40.     jle  quit        ;
  41.     db   0CBh        ;RET far
  42. quit:    ret            ;RET near
  43. _read_char ENDP
  44. _TEXT    ENDS
  45.     END
  46.